<?php
include_once 'inc/config.inc.php';
include_once 'inc/mysql.inc.php';
include_once 'inc/tool.inc.php';

$template['title'] = '首页';
$link = connect();

?>
<?php include_once 'inc/header.inc.php'?>
<!-- 主体部分开始 -->
    <!-- 热门动态版块 -->
    <div id='hot' class="content-box">
        <div class="title">热门动态</div>
        <ul class="newList">
            <li><a href="">[库队1] 1111111</a></li>
            <li><a href="">[库队2] 1111111</a></li>
            <li><a href="">[库队3] 1111111</a></li>
            <li><a href="">[库队4] 1111111</a></li>
            <li><a href="">[库队5] 1111111</a></li>
        </ul>
    </div>

    <!-- 父版块 -->
    <?php
    $query = "select * from kuse_father_module order by sort desc";
    $result_father = execute($link, $query);
    while($data_father = mysqli_fetch_assoc($result_father)){
    ?>
        <!-- 父版块 -->
        <div class="box content-box">
            <div class="title">
                <?php echo $data_father['module_name'] ?>
            </div>
            <div class="childList clearfix">
                <!-- 子版块 -->
                <?php
                $query = "select * from kuse_son_module where father_module_id = {$data_father['id']}";
                $result_son = execute($link, $query);
                if(mysqli_num_rows($result_son)){
                    while($data_son = mysqli_fetch_assoc($result_son)){
                        $query = "select count(*) from kuse_content where module_id = {$data_son['id']} and time > CURDATE()";
                        $count_today = num($link, $query);
                        $query = "select count(*) from kuse_content where module_id = {$data_son['id']}";
                        $count_all = num($link, $query);
$html = <<<A
<div class="childBox new">
    <h2>
        <a href="#">{$data_son['module_name']}</a>
        <span>(今天{$count_today})</span>
    </h2>
    帖子：{$count_all}<br>
</div>
A;
                        echo $html;
                    }
                }else{
                    echo '<div style="padding: 10px 0;">暂无子版块</div>';
                }
                ?>
            </div>
        </div>
    <?php } ?>
    </div>
<!-- 主体部分结束 -->

<?php include_once 'inc/footer.inc.php'?>